package com.stlm2.controller;

import com.stlm2.dems.entity.RefundLog;
import com.stlm2.dems.entity.User;
import com.stlm2.dems.service.RefundLogService;
import com.stlm2.util.codecontent.CodeContent;
import org.apache.commons.lang.math.NumberUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Created by apple on 2017.11.12.
 */
@Controller
@RequestMapping("/refundLogC")
public class RefundLogController {

    @Resource
    private RefundLogService refundLogService;




    /**
     * 退款/售后 list
     * ffl
     * 2017-11-12 15:31:20
     * @param token
     * @param userName
     * @param cnName
     * @param code
     * @param referCode
     * @param refundStateValue
     * @param pageNum
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/search.json",produces = "application/json;charset=utf-8")
    public String search(String token,String userName,String cnName,String code ,String referCode,String refundStateValue,String pageNum){
        return refundLogService.search(token, userName, cnName, code, referCode,refundStateValue ,pageNum);
    }



    /**
     * 获取记录详情
     * ffl
     * 2017-11-12 16:09:16
     * @param token
     * @param id
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getById.json",produces = "application/json;charset=utf-8")
    public String getByIdForDetail(String token,String id){
      return refundLogService.getByIdForDetail(token, id);
    }


    /**
     * 处理退款/售后
     * ffl
     * 2017-11-13 09:27:40
     * @param token
     * @param id
     * @param handleValue 2不同意  3同意
     * @param refundMoney
     * @param num
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/edit.json",produces = "application/json;charset=utf-8")
    public String handleRefundLog(String token,String id,String handleValue,String refundMoney,String num) {
        return refundLogService.handleRefundLog(token, id, handleValue, refundMoney, num);
    }



    @RequestMapping(value="/list",produces="application/json;charset=UTF-8")
    public ModelAndView list(ModelAndView modelAndView){
        modelAndView.setViewName("/refundLog/list");
        return modelAndView;
    }


    @RequestMapping(value="/detail",produces="application/json;charset=UTF-8")
    public ModelAndView edit(ModelAndView modelAndView,String id){
        modelAndView.addObject("id",id);
        modelAndView.setViewName("/refundLog/detail");
        return modelAndView;
    }

}
